﻿@using TD.Common.Kendo.Mvc5.Grid
@using TD.Common.Kendo.Mvc5.Common
@using TD.Common.Web.Mvc

@model TD.CTS.Data.Entities.Trial

@section head{
    <link href="@Url.Content("~/Content/td/td.kendo.grid.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/td/td.kendo.tabstrip.css")" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/td/td.kendo.grid.js")"></script>
}

@Html.HiddenFor(model => model.Code)
@Html.HiddenFor(model => model.Version)

@(Html.Kendo().TabStrip()
    .Name("TabStrip")
    .Animation(false)
    .Events(events => events.Show("ShowTab"))
    .Items(tabs =>
        {
            tabs.Add().Text("Роли")
                .Selected(true)
                .ContentHtmlAttributes(new { style = "padding:0;" })
                .Content(@<text>@Html.Partial("EditorTemplates/RolesEditor")</text>);
            tabs.Add().Text("Стоимость визитов")
                .ContentHtmlAttributes(new { style = "padding:0;" })
                .Content(@<text>@Html.Partial("EditorTemplates/VisitCostsEditor", Model.Code)</text>);
            tabs.Add().Text("Статьи доходов")
                .ContentHtmlAttributes(new { style = "padding:0;" })
                .Content(@<text>@Html.Partial("EditorTemplates/IncomeArticlesEditor", Model.Code)</text>);
        }
    )
)

<script>
    $(document).ready(function () {
        SetContentBlock($("#TabStrip .k-content"));

        kendo_grid_init($("#ProcedureRolesGrid"));

        kendo_grid_init($("#VisitsGrid"));

        kendo_grid_init($("#IncomeArticlesGrid"));

        $(window).bind("resize", function () {
            var tabStrip = $("#TabStrip").data("kendoTabStrip");
            var tab = tabStrip.select();
            var index = tab.index();
            var conteiner = tabStrip.contentElements[index];
            StretchGrid($(conteiner), $(conteiner.firstElementChild));
        });
    });

    function GetTrialCode() {
        return { TrialCode: $("#Code").val(), TrialVersion: $("#Version").val() };
    }

    function ShowTab(e) {
        StretchGrid($(e.contentElement), $(e.contentElement.firstElementChild));
    }

    function ProcedureRolesGridBound(e) {
        this.expandRow(this.tbody.find("tr.k-master-row"));
    }
</script>


